

let mixins={
     created() {
        console.log('vue init') 
     },
     mounted() {
        $('.page-wrapper').show()
     },
     data() {
        return {
           loading:false,
           progress:1,
           form:{
            name:'李四', //用户称呼
            sex:0, //性别，0为女，1为男 
            age:'25', //用户年龄
            yearIncome:'92353', //用户年收入
            yearExpendRatio:'12', //用户个人年花销的占比
            planRetireAge:'55', //用户计划退休年龄
            anticipantMedicalType:2, //希望给到哪种品质的医疗照护(1一般水平,2优越水平,3尊贵水平)
            safeguardAge:'99', //保障年龄
            socialMedicalInsurance:0, //是否购买社会医疗保险（1是0否）
            lifeInsurance:'342', //人寿保险保额
            accidentInsurance:'423', //意外保险保额
            seriousIllnessInsurance:'342', //重疾保险保额
            medicalInsurance:'324', //医疗保险保额
            spouse:0, //用户是否有配偶（1是0否）
            spouseAge:'22', //配偶年龄
            spouseYearIncome:'3322', //配偶年收入
            spouseExpendRatio:'5', //配偶个人年花销的占比
            spouseRetireAge:'55', //配偶计划退休年龄
            spouseSocialMedicalInsurance:0, //配偶是否购买社会医疗保险（1是0否）
            spouseLifeInsurance:'234', //配偶人寿保险保额
            spouseAccidentInsurance:'424', //配偶意外保险保额
            spouseSeriousIllnessInsurance:'423', //配偶重疾保险保额
            spouseMedicalInsurance:'453', //配偶医疗保险保额
            children:0, //用户是否有子女（1是0否）
            childrenList:[
               // {
               //    age:'', //年龄
               //    socialMedicalInsurance:0, //是否购买社保
               //    lifeInsurance:'333', //人寿保险保额
               //    accidentInsurance:'333', //意外保险保额
               //    seriousIllnessInsurance:'333', //重疾保险保额
               //    medicalInsurance:'333', //医疗保险保额
               // }
            ] 
           }
        }
     },
     computed: {
        childNumber(){
          return  this.form.childrenList.length
        }
     },
     methods: {
         preItem(){
           if (this.progress==1) {
               return false
           }
           if (this.form.spouse==0&&this.form.children==0&&this.progress==3) {
            this.progress-=2
         }else{
            this.progress--
         }
         },
         nextItem(){
            if (this.form.spouse==0&&this.form.children==0&&this.progress==1) {
               this.progress+=2
            }else{
               this.progress++
            }
         },
         overInput(){
            
            let _this=this
            let params=null;
            params={...this.form}
            params.userId='19e3c505ec5d45fc89e40a83029b60b6'
            params.children=params.children?1:0
            params.spouse=params.spouse?1:0
            // params.userPhone= '18282668833'   
            console.log(params)   
            _this.requestFun('/newfinancial/h5/family/enteringFamilyPlan', params,false).then(function(data) {
                console.log(data)
                if (data.resultCode=='0000') {
                     _this.toast("发送成功")
       
                } else {
                 _this.toast(data.resultMessage)
                }
             });
            // window.location.href=window.location.href.replace('newReport','planReport')
         },
         addChild(){
            this.form.childrenList.push(
               {
                  age:'', //年龄
                  socialMedicalInsurance:0, //是否购买社保
                  lifeInsurance:'', //人寿保险保额
                  accidentInsurance:'', //意外保险保额
                  seriousIllnessInsurance:'', //重疾保险保额
                  medicalInsurance:'', //医疗保险保额
               }
            )

         },
         reduceChild(){
            this.form.childrenList.pop()
         },
         level(type){
            this.form.anticipantMedicalType=type
         },
         switchfunc(origin,flag,index){
             if (origin=='sex') {
                this.form[origin]=flag
             }
             if (origin=='socialMedicalInsurance') {
               this.form[origin]=flag
            }
            if (origin=='spouseSocialMedicalInsurance') {
               this.form[origin]=flag
            }
            if (origin=='childrenList') {
               this.form[origin][index]['socialMedicalInsurance']=flag
            }
         },
         checkbox(origin){
            // if (this.form[origin]==0||this.form[origin]==false) {
            //    this.form[origin]=1
            // }else{
            //    this.form[origin]=0
            // }
         }
     },
}




